package com.lxyk.dao.student;

import com.lxyk.domain.StudentVO2;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface RefundDao {

    //添加退费信息
    @Insert("insert into refund values(null,#{nature},#{money},#{applyTime},#{handleTime},#{reason},#{statusRefund},#{sid})")
    void addRefund(StudentVO2 student);

    //修改学生退费信息
    @Update("update refund set statusRefund=0 where sid=#{id}")
    void updateRefund(StudentVO2 student);

    //修改学生退费标识
    @Update("update student set refundFlag=1 where id=#{id}")
    void updateStudent(StudentVO2 student);

    //根据id查询退费信息
    @Select("select * from student,classes where student.cid=classes.id and student.id=#{id}")
    StudentVO2 findRefundById(Integer id);

    //查询当前班级退费信息
    @Select("select * from student,classes,refund where student.id=refund.sid and student.cid=classes.id and student.refundFlag=1 and refund.statusRefund=0 and cid=#{cid}")
    List<StudentVO2> refundByCid(Integer cid);

    //根据条件模糊查询退费信息
    List<StudentVO2> findRefundByCondition(StudentVO2 vo);

    //查询当前班级退费人数
    @Select("SELECT count(*) from student,classes,refund where student.id=refund.sid and student.cid=classes.id and student.refundFlag=1 and refund.statusRefund=0 and cid=#{cid}")
    int findCountByCid(Integer cid);

}
